package it.polimi.traveldream.ejb.dtocreator;

import it.polimi.traveldream.ejb.entities.User;

import it.polimi.traveldream.ejbclient.dtos.UserDTO;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class UserDTOCreator {
	public static UserDTO createUser(User entity) {
		return entity != null ? new UserDTO(entity.getId(), entity.getEmail(), entity.getName(),entity.getPassword(),
				entity.getRegistration(), entity.getRole(), entity.getSurname())
		: null;
	}
	
	public static List<UserDTO> createUserList(Collection<User> entities) {
		if(entities != null && !entities.isEmpty()) {
			List<UserDTO> users = new ArrayList<UserDTO>();
			for(User entity : entities) {
				users.add(createUser(entity));
			}
			return users;
		}
		return null;
	}
	
}
